import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QTextEdit, QAction, QToolBar
from PyQt5.QtGui import QIcon

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        # 设置窗口标题和大小
        self.setWindowTitle("Qt 语言家")
        self.setGeometry(100, 100, 800, 600)

        # 创建文本编辑区
        self.text_edit = QTextEdit(self)
        self.setCentralWidget(self.text_edit)

        # 创建菜单栏
        menu_bar = self.menuBar()

        # 创建文件菜单
        # file_menu = menu_bar.addMenu('文件(&F)')
        # edit_menu = menu_bar.addMenu('编辑(&E)')
        # view_menu = menu_bar.addMenu('查看(&V)')
        # help_menu = menu_bar.addMenu('帮助(&H)')

        # 创建工具栏
        tool_bar = QToolBar(self)
        self.addToolBar(tool_bar)

        # 添加操作到工具栏
        new_action = QAction(QIcon(), '新建', self)
        open_action = QAction(QIcon(), '打开', self)
        save_action = QAction(QIcon(), '保存', self)

        tool_bar.addAction(new_action)
        tool_bar.addAction(open_action)
        tool_bar.addAction(save_action)

        # 添加操作到菜单
        # file_menu.addAction(new_action)
        # file_menu.addAction(open_action)
        # file_menu.addAction(save_action)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())